package cn.itcast.user.controller;

import cn.itcast.user.service.UserService;
import cn.itcast.user.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")//来映射URL对外提供一个接口user/id  还可以指定“请求方法、请求参数和请求头”的映射请求
public class Controller {

    @Autowired
    private UserService userService;

    @GetMapping("/{id}") //路径变量
    public User queryById(@PathVariable("id") Long id){  //路径变量使用
        return userService.queryById(id);
    }
}
